package com.huatai.dataservice.fire.firemodel;

import java.util.Arrays;

/**
 * packageName com.huatai.dataservice.fire.firemodel
 *
 * @author gaowengui
 * @version JDK 8
 * @className PoliceTypeCountEnum
 * @date 2025/6/10
 * @description TODO
 */
public enum PoliceTypeCountEnum {

    FIRE_FIGHTING("居民区域"),

    SOCIAL_ASSISTANCE("经营场所"),

    EMERGENCY_RESCUE("社会校园"),

    JIUXIAO_EARA("九小场所"),
    OTHER_MOBILIZATION("其他类型");

    private final String displayName;

    PoliceTypeCountEnum(String displayName) {
        this.displayName = displayName;
    }

    // 1. 修复类型匹配逻辑（通过displayName匹配）
    public static PoliceTypeCountEnum fromDisplayName(String displayName) {
        return Arrays.stream(values())
                .filter(type -> type.getDisplayName().equals(displayName))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException(
                        "无效的救援类型名称: " + displayName +
                                "，有效类型：" + Arrays.toString(values())
                ));
    }

    public static PoliceTypeCountEnum getPeriod(String type) {
        for (PoliceTypeCountEnum rescueType : values()) {
            if (type.equals(RescueTypeEnum.EMERGENCY_RESCUE)) {
                return rescueType;
            } else if (RescueTypeEnum.FIRE_FIGHTING.equals(rescueType)) {
                return rescueType;
            } else if (RescueTypeEnum.SOCIAL_ASSISTANCE.equals(rescueType)) {
                return rescueType;
            } else if (RescueTypeEnum.OTHER_MOBILIZATION.equals(rescueType)) {
                return rescueType;
            }
        }
        throw new IllegalArgumentException("无效: " + type);
    }

    public String getDisplayName() {
        return displayName;
    }
}
